package LeetCode;

public class LC_275_HIndexII {

    public static void main(String[] args) {

    }

    static class Solution {
        public int hIndex(int[] citations) {
            int level = 0, n = citations.length, left = 0, right = n - 1;
            while (left <= right) {
                int mid = left + (right - left) / 2;
                if (citations[mid] >= n - mid) {
                    level = n - mid;
                    right = mid - 1;
                } else left = mid + 1;
            }
            return level;
        }

    }
}